// see http://vuejs-templates.github.io/webpack for documentation.
var path = require('path')
var online = 'http://60.205.176.129:8080'
var inline = 'http://10.153.163.182:8080'
var debugEnv = inline
var onlineEnv = online

module.exports = {
  build: {
    env: require('./prod.env'),
    index: path.resolve(__dirname, '../dist/index.html'),
    assetsRoot: path.resolve(__dirname, '../dist'),
    assetsSubDirectory: 'static',
    assetsPublicPath: '/',
    productionSourceMap: true,
    // Gzip off by default as many popular static hosts such as
    // Surge or Netlify already gzip all static assets for you.
    // Before setting to `true`, make sure to:
    // npm install --save-dev compression-webpack-plugin
    productionGzip: false,
    productionGzipExtensions: ['js', 'css'],
    // Run the build command with an extra argument to
    // View the bundle analyzer report after build finishes:
    // `npm run build --report`
    // Set to `true` or `false` to always turn it on or off
    bundleAnalyzerReport: process.env.npm_config_report
  },
  debug: {
    env: require('./dev.env'),
    port: 2222,
    autoOpenBrowser: true,
    assetsSubDirectory: 'static',
    assetsPublicPath: '/',
    // http://10.153.163.182:8080
    proxyTable: {
      '/device': {
        target: debugEnv
      },
      '/data': {
        target: debugEnv
      },
      '/project': {
        target: debugEnv
      },
      '/open': {
        target: debugEnv
      },
      '/company': {
        target: debugEnv
      },
      '/module': {
        target: debugEnv
      },
      '/login': {
        target: debugEnv
      },
      '/gateway': {
        target: debugEnv
      }
    },
    // CSS Sourcemaps off by default because relative paths are "buggy"
    // with this option, according to the CSS-Loader README
    // (https://github.com/webpack/css-loader#sourcemaps)
    // In our experience, they generally work as expected,
    // just be aware of this issue when enabling this option.
    cssSourceMap: false
  },
  release: {
    env: require('./prod.env'),
    port: 80,
    autoOpenBrowser: true,
    assetsSubDirectory: 'static',
    assetsPublicPath: '/',
    proxyTable: {
      '/device': {
        target: onlineEnv
      },
      '/data': {
        target: onlineEnv
      },
      '/project': {
        target: onlineEnv
      },
      '/open': {
        target: onlineEnv
      },
      '/company': {
        target: onlineEnv
      },
      '/module': {
        target: onlineEnv
      },
      '/login': {
        target: onlineEnv
      },
      '/gateway': {
        target: onlineEnv
      }
    }
  },
  dev: {
    env: require('./dev.env'),
    port: 2222,
    autoOpenBrowser: true,
    assetsSubDirectory: 'static',
    assetsPublicPath: '/',
    proxyTable: {
      '/device': {
        target: 'http://127.0.0.1:2222',
        pathRewrite: {
          '^/device/all': '/static/debug/allDevice.json',
          '^/device/itemdata': '/static/debug/historyDataList.json',
        }
      },
      '/data':  {
        target: 'http://127.0.0.1:2222',
        pathRewrite: {
          '^/data/current': '/static/debug/currentDataList.json',
          '^/data/history/dataitem/': '/static/debug/historyDataList.json',
        }
      },
      '/project': {
        target: 'http://127.0.0.1:2222',
        pathRewrite: {
          '^/project/create': '/static/debug/addProject.json',
          '^/project/module/find': '/static/debug/moduleData.json',
          '^/project/find': '/static/debug/projectInfo.json',
          '^/project/module/update': '/static/debug/moduleData.json',
          '^/project': '/static/debug/projectList.json'
        }
      },
      '/module': {
        target: 'http://127.0.0.1:2222',
        pathRewrite: {
          '^/module/update': '/static/debug/addProject.json'
        }
      },
      '/gateway': {
        target: 'http://127.0.0.1:2222',
        pathRewrite: {
          '^/gateway/all': '/static/debug/gatewayList.json'
        }
      },
      '/company': {
        target: 'http://127.0.0.1:2222',
        pathRewrite: {
          '^/company/login': '/static/debug/login.json'
        }
      }
    },
    // CSS Sourcemaps off by default because relative paths are "buggy"
    // with this option, according to the CSS-Loader README
    // (https://github.com/webpack/css-loader#sourcemaps)
    // In our experience, they generally work as expected,
    // just be aware of this issue when enabling this option.
    cssSourceMap: false
  }
}
